﻿<%@ Page Title="" Language="C#" 
MasterPageFile="~/MasterPage.master" AutoEventWireup="true" 
CodeBehind="AtividadeBrowser.aspx.cs" Inherits="EGym10.Cadastros.AtividadeBrowser" %>
<asp:Content ID="mainContent" ContentPlaceHolderID="mainPlace" runat="Server">
    <script type="text/javascript" src="../includes/default.js"></script>
    <br />
    <div class="Title">
        Gerenciamento de Atividades
    </div>
    <br />    
    <asp:GridView ID="grdMain" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        CellPadding="4" DataSourceID="dsAtividade" ForeColor="#333333" GridLines="None"
        PageSize="15" Width="500px" DataKeyNames="AtividadeID">
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:BoundField DataField="AtividadeID" HeaderText="ID" InsertVisible="False" SortExpression="AtividadeID"
                ReadOnly="True" />
            <asp:TemplateField HeaderText="Nome" SortExpression="Nome">
                <EditItemTemplate>
                    <asp:TextBox ID="txtNome" runat="server" MaxLength="35" Text='<%# Bind("Nome") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblNome" runat="server" Text='<%# Bind("Nome") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Dura&#231;&#227;o (meses)" SortExpression="Duracao">
                <EditItemTemplate>
                    <asp:TextBox ID="txtDuracao" runat="server" MaxLength="2" SkinID="Number" Text='<%# Bind("Duracao") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblDuracao" runat="server" Text='<%# Bind("Duracao") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Valor da Parcela" SortExpression="ValorParcela">
                <EditItemTemplate>
                    <asp:TextBox ID="txtValorParcela" runat="server" MaxLength="6" SkinID="Number" Text='<%# Bind("ValorParcela") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblValorParcela" runat="server" Text='<%# Bind("ValorParcela") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Desconto" SortExpression="Desconto">
                <EditItemTemplate>
                    <asp:TextBox ID="txtDesconto" runat="server" SkinID="Number" Text='<%# Bind("Desconto") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblValorDesconto" runat="server" Text='<%# Bind("Desconto") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Juros / Dia" SortExpression="Juros">
                <EditItemTemplate>
                    <asp:TextBox ID="txtJuros" runat="server" SkinID="Number" Text='<%# Bind("Juros") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblJuros" runat="server" Text='<%# Bind("Juros") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="lnkEdit" runat="Server" CommandName="Edit">Editar</asp:LinkButton>
                    |
                    <asp:LinkButton ID="lnkDelete" runat="Server" CommandName="Delete" CausesValidation="False"
                        OnClientClick="javascript:return confirm('Deseja realmente excluir este registro?');">Excluir</asp:LinkButton>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:LinkButton ID="lnkUpdate" runat="Server" CommandName="Update">Salvar</asp:LinkButton>
                    |
                    <asp:LinkButton ID="lnkCancel" runat="Server" CommandName="Cancel" CausesValidation="False">Cancelar</asp:LinkButton>
                </EditItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            Nenhum registro cadastrado.
        </EmptyDataTemplate>
        <RowStyle BackColor="#EFF3FB" />
        <EditRowStyle BackColor="#2461BF" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <br />
    <asp:DetailsView ID="dtlMain" runat="server" AutoGenerateRows="False" CellPadding="4"
        DataSourceID="dsAtividade" ForeColor="#333333" GridLines="None" Height="50px"
        Width="500px" DefaultMode="Insert" DataKeyNames="AtividadeID">
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
        <EditRowStyle BackColor="#2461BF" />
        <RowStyle BackColor="#EFF3FB" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <Fields>
            <asp:TemplateField HeaderText="Nome" SortExpression="Nome">
                <InsertItemTemplate>
                    <asp:TextBox ID="txtNome" runat="server" MaxLength="35" Text='<%# Bind("Nome") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Dura&#231;&#227;o (meses)" SortExpression="Duracao">
                <InsertItemTemplate>
                    <asp:TextBox ID="txtDuracao" runat="server" MaxLength="2" SkinID="Number" Text='<%# Bind("Duracao") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Valor da Parcela" SortExpression="ValorParcela">
               <InsertItemTemplate>
                    <asp:TextBox ID="txtValorParcela" runat="server" MaxLength="6" SkinID="Number" Text='<%# Bind("ValorParcela") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Desconto" SortExpression="Desconto">
                <InsertItemTemplate>
                    <asp:TextBox ID="txtDesconto" runat="server" SkinID="Number" Text='<%# Bind("Desconto") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Juros / Dia" SortExpression="Juros">
                <InsertItemTemplate>
                    <asp:TextBox ID="txtJuros" runat="server" SkinID="Number" Text='<%# Bind("Juros") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <InsertItemTemplate>
                    <asp:LinkButton ID="lnkInsert" runat="Server" CommandName="Insert">Salvar</asp:LinkButton>
                    |
                    <asp:LinkButton ID="lnkCancel" runat="Server" CommandName="Cancel" CausesValidation="False">Cancelar</asp:LinkButton>
                </InsertItemTemplate>
            </asp:TemplateField>
        </Fields>
        <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:DetailsView>
    <asp:SqlDataSource ID="dsAtividade" runat="server" ConnectionString="<%$ ConnectionStrings:AcademiaConnectionString %>"
        SelectCommand="SELECT [AtividadeID], [Nome], [ValorParcela], [Duracao],  [Desconto], [Juros] FROM [Atividade] ORDER BY [Nome]"
        DeleteCommand="DELETE FROM Atividade WHERE AtividadeID = @AtividadeID"
        InsertCommand="set language portuguese Insert INTO Atividade(Nome, ValorParcela, Duracao, Juros, Desconto) VALUES (@Nome, @ValorParcela, @Duracao, @Juros, @Desconto)"
        UpdateCommand="Update Atividade SET Nome = @Nome, ValorParcela = @ValorParcela, Duracao = @Duracao, Juros = @Juros, Desconto = @Desconto WHERE (AtividadeID = @AtividadeID)">
        <DeleteParameters>
            <asp:Parameter Name="AtividadeID" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Nome" />
            <asp:Parameter Name="ValorParcela" />
            <asp:Parameter Name="Duracao" />
            <asp:Parameter Name="Juros" />
            <asp:Parameter Name="Desconto" />
            <asp:Parameter Name="AtividadeID" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Nome" />
            <asp:Parameter Name="ValorParcela" />
            <asp:Parameter Name="Duracao" />
            <asp:Parameter Name="Juros" />
            <asp:Parameter Name="Desconto" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>
